/**
 * Project Name:gc.sms.mvn
 * File Name:ResponseResultUtil.java
 * Package Name:com.clps.dev.sms.util.result
 * @date 2018-12-07 16:05:21 
 * Copyright (c) 2018, www.clpsglobal.com All Rights Reserved.
 *
 */
package com.clps.dev.sms.util.result;

import java.util.List;

import com.clps.dev.sms.common.result.ResponseResult;
import com.clps.dev.sms.util.page.PageBean;
import com.clps.dev.sms.util.tree.TreeBean;

/**
 * @ClassName: ResponseResultUtil <br/>
 * @Description: <br/>
 *               用于返回统一结果对象（ResponseRusult）的工具类
 *
 * @date 2018-12-07 16:05:21 <br/>
 *
 * @author long.ma
 * @version V1.0
 * @since JDK 1.8
 */
public class ResponseResultUtil {

	// 返回成功的情况
	/**
	 * @author long.ma 
	 * @description success <br/>
	 *              操作成功，返回所有信息：state、message、data、pageInfo和treeInfo
	 *              
	 * @param Integer state HTTP状态码
	 * @param String message 操作的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param PageBean<T> 分页对象
	 * @param List<TreeBean<T>>	包含了树形结构的集合对象
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state, String message, Object data, PageBean<T> pageInfo,
			List<TreeBean<T>> treeInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setPageInfo(pageInfo);
		responseResult.setTreeInfo(treeInfo);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：state、message、data和pageInfo
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param PageBean<T> pageInfo 分页对象
	 * @return <T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state, String message, Object data, PageBean<T> pageInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setPageInfo(pageInfo);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：state、message、data和treeInfo
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param List<TreeBean<T>>	treeInfo 包含了树形结构的集合对象
	 * @return	<T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state, String message, Object data, List<TreeBean<T>> treeInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setTreeInfo(treeInfo);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：state、message和data
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @return	<T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state, String message, Object data) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：state和message
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作的信息
	 * @return	<T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state, String message) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		return responseResult;
	}

	/**
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：message和data
	 * 
	 * @param String message 操作的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @return	<T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(String message, Object data) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setData(data);
		responseResult.setMessage(message);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：message和pageInfo
	 * 
	 * @param String message 操作的信息
	 * @param PageBean<T> pageInfo 分页对象
	 * @return	<T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(String message, PageBean<T> pageInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setMessage(message);
		responseResult.setPageInfo(pageInfo);
		return responseResult;
	}

	/**
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：message和treeInfo
	 *
	 * @param String message 操作的信息
	 * @param PageBean<T> pageInfo 分页对象
	 * @param List<TreeBean<T>>	treeInfo 包含了树形结构的集合对象
	 * @return <T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(String message, List<TreeBean<T>> treeInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setMessage(message);
		responseResult.setTreeInfo(treeInfo);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：state
	 * 
	 * @param Integer state HTTP状态码
	 * @return <T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(Integer state) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		return responseResult;
	}

	/**
	 * @author long.ma
	 * @description success <br/>
	 *              操作成功，返回：message
	 * 
	 *
	 * @param String message 操作成功的信息
	 * @return <T> ResponseResult<T>	返回响应结果对象
	 */
	public static <T> ResponseResult<T> success(String message) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setMessage(message);
		return responseResult;
	}

	// 返回错误的情况
	/**
	 * 
	 * @author long.ma
	 * @description error <br/>
	 *              操作失败，返回：state、message、data、pageInfo和treeInfo
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作失败的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param PageBean<T> 分页对象
	 * @param List<TreeBean<T>>	treeInfo 包含了树形结构的集合对象
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(Integer state, String message, Object data, PageBean<T> pageInfo,
			List<TreeBean<T>> treeInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setPageInfo(pageInfo);
		responseResult.setTreeInfo(treeInfo);
		return responseResult;
	}

	/**
	 * 
	 * @description error <br/>
	 *              操作失败，返回：state、message、data和pageInfo
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作失败的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param PageBean<T> pageInfo	分页对象
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */

	public static <T> ResponseResult<T> error(Integer state, String message, Object data, PageBean<T> pageInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setPageInfo(pageInfo);

		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description error <br/>
	 *              操作失败，返回：state、message、data和treeInfo
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作失败的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @param List<TreeBean<T>>	treeInfo 包含了树形结构的集合对象
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(Integer state, String message, Object data, List<TreeBean<T>> treeInfo) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		responseResult.setTreeInfo(treeInfo);
		return responseResult;
	}

	/**
	 * 
	 * @description error <br/>
	 *              操作失败，返回：state、message和data
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作失败的信息
	 * @param Object data 	操作完成获取的Object对象数据
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(Integer state, String message, Object data) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		responseResult.setData(data);
		return responseResult;
	}

	/**
	 * @author long.ma
	 * @description error <br/>
	 *              操作失败，返回：state和message
	 * 
	 * @param Integer state HTTP状态码
	 * @param String message 操作失败的信息
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(Integer state, String message) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		responseResult.setMessage(message);
		return responseResult;
	}

	/**
	 * 
	 * @author long.ma
	 * @description error <br/>
	 *              操作失败，返回：state
	 * 
	 * @param Integer state HTTP状态码
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(Integer state) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setState(state);
		return responseResult;
	}

	/**
	 * @author long.ma
	 * @description error <br/>
	 *              操作失败，返回： message
	 * 
	 * @param String message 操作失败的信息
	 * @return <T> ResponseResult<T> 返回响应结果对象
	 */
	public static <T> ResponseResult<T> error(String message) {
		ResponseResult<T> responseResult = new ResponseResult<T>();
		responseResult.setMessage(message);
		return responseResult;
	}
}
